home *** CD-ROM | disk | FTP | other *** search
- package symantec.itools.awt;
-
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Dimension;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.awt.Rectangle;
-
- public class LabelButton extends ButtonBase implements AlignStyle, BevelStyle {
- public static final int INDENT_ZERO = 0;
- public static final int INDENT_ONE = 1;
- public static final int INDENT_TWO = 2;
- protected String sLabelButton;
- protected boolean showLabel;
- private int alignStyle;
- private int bevelStyle;
- private Color color1;
- private Color color2;
- private Color textColor;
- private Color borderedColor;
- // $FF: renamed from: fm java.awt.FontMetrics
- private FontMetrics field_0;
- private int xTemp;
- private int yTemp;
- private int indent;
- private int textWidth;
- private int textAscent;
- private int textHeight;
- private boolean bOsFlag;
-
- public LabelButton() {
- this("", 1, 1, Color.black, 0, true);
- }
-
- public LabelButton(String var1, int var2, int var3) {
- this(var1, var2, var3, Color.black, 0, true);
- }
-
- public LabelButton(String var1, int var2, int var3, Color var4) {
- this(var1, var2, var3, var4, 0, true);
- }
-
- public LabelButton(String var1, int var2, int var3, int var4) {
- this(var1, var2, var3, Color.black, var4, true);
- }
-
- public LabelButton(String var1, int var2, int var3, Color var4, int var5, boolean var6) {
- this.bOsFlag = false;
- String var7 = System.getProperty("os.name");
- if (!var7.startsWith("S") && !var7.startsWith("OSF")) {
- this.bOsFlag = false;
- } else {
- this.bOsFlag = true;
- this.setFont(new Font("Dialog", 0, 10));
- }
-
- Font var8 = ((Component)this).getFont();
- if (var8 == null) {
- this.field_0 = ((Component)this).getFontMetrics(new Font("Dialog", 0, 12));
- } else {
- this.field_0 = ((Component)this).getFontMetrics(var8);
- }
-
- this.setText(var1);
- this.textColor = var4;
- this.borderedColor = Color.black;
- this.setBorderIndent(var5);
- this.setAlignStyle(var2);
- this.setBevelStyle(var3);
- super.showFocus = true;
- this.showLabel = var6;
- }
-
- public void setAlignStyle(int var1) {
- this.alignStyle = var1;
- }
-
- public int getAlignStyle() {
- return this.alignStyle;
- }
-
- public void setBevelStyle(int var1) {
- this.bevelStyle = var1;
- switch (var1) {
- case 0:
- this.color1 = Color.black;
- this.color2 = Color.gray;
- return;
- case 1:
- this.color1 = Color.gray;
- this.color2 = Color.black;
- return;
- case 2:
- this.color1 = this.borderedColor;
- this.color2 = this.borderedColor;
- return;
- default:
- this.color1 = this.color2 = null;
- }
- }
-
- public int getBevelStyle() {
- return this.bevelStyle;
- }
-
- public void setBorderIndent(int var1) {
- if (var1 < 0) {
- this.indent = 0;
- } else if (var1 > 2) {
- this.indent = 2;
- } else {
- this.indent = var1;
- }
- }
-
- public int getBorderIndent() {
- return this.indent;
- }
-
- public void setBorderedColor(Color var1) {
- this.borderedColor = var1;
- if (this.bevelStyle == 2) {
- this.color1 = var1;
- this.color2 = var1;
- }
-
- ((Component)this).invalidate();
- }
-
- public void setText(String var1) {
- Font var2 = ((Component)this).getFont();
- if (var2 == null) {
- this.field_0 = ((Component)this).getFontMetrics(new Font("Dialog", 0, 12));
- } else {
- this.field_0 = ((Component)this).getFontMetrics(var2);
- }
-
- this.sLabelButton = var1;
- this.textAscent = this.field_0.getAscent();
- this.textHeight = this.field_0.getHeight();
- this.textWidth = this.field_0.stringWidth(this.sLabelButton);
- }
-
- public String getText() {
- return this.sLabelButton;
- }
-
- public void setTextColor(Color var1) {
- this.textColor = var1;
- }
-
- public Color getTextColor() {
- return this.textColor;
- }
-
- public void setShowLabel(boolean var1) {
- this.showLabel = var1;
- }
-
- public boolean getShowLabel() {
- return this.showLabel;
- }
-
- public void paint(Graphics var1) {
- Dimension var2 = ((Component)this).size();
- Rectangle var3 = ((Component)this).bounds();
- this.yTemp = var3.height / 2 + this.textAscent / 2;
- switch (this.alignStyle) {
- case 0:
- if (this.bevelStyle == 2) {
- this.xTemp = 4;
- } else {
- this.xTemp = 8;
- }
- break;
- case 1:
- this.xTemp = (var3.width - this.textWidth) / 2;
- break;
- case 2:
- this.xTemp = var3.width - this.textWidth;
- if (this.bevelStyle == 2) {
- this.xTemp -= 6;
- } else {
- this.xTemp -= 10;
- }
- }
-
- switch (this.bevelStyle) {
- case 0:
- super.pressed = !super.pressed;
- super.paint(var1);
- super.pressed = !super.pressed;
- if (this.showLabel) {
- var1.setColor(this.textColor);
- if (super.pressed) {
- var1.drawString(this.sLabelButton, this.xTemp - super.pressedAdjustment, this.yTemp - super.pressedAdjustment);
- return;
- }
-
- var1.drawString(this.sLabelButton, this.xTemp, this.yTemp);
- return;
- }
- break;
- case 1:
- super.paint(var1);
- if (this.showLabel) {
- var1.setColor(this.textColor);
- if (super.pressed) {
- var1.drawString(this.sLabelButton, this.xTemp + super.pressedAdjustment, this.yTemp + super.pressedAdjustment);
- return;
- }
-
- var1.drawString(this.sLabelButton, this.xTemp, this.yTemp);
- return;
- }
- break;
- case 2:
- var1.setColor(((Component)this).getForeground());
- var1.drawRect(this.indent, this.indent, var2.width - 1 - this.indent - this.indent, var2.height - 1 - this.indent - this.indent);
- case 3:
- if (this.showLabel) {
- var1.setColor(this.textColor);
- var1.drawString(this.sLabelButton, this.xTemp, this.yTemp);
- }
-
- if (super.showInfoTip && super.doInfoTip) {
- ((ButtonBase)this).drawInfoTip();
- }
- }
-
- }
-
- public void setFont(Font var1) {
- super.setFont(var1);
- this.field_0 = ((Component)this).getFontMetrics(((Component)this).getFont());
- this.textAscent = this.field_0.getAscent();
- this.textHeight = this.field_0.getHeight();
- this.textWidth = this.field_0.stringWidth(this.sLabelButton);
- }
-
- public Dimension preferredSize() {
- Dimension var1 = ((Component)this).size();
- Dimension var2 = this.minimumSize();
- return new Dimension(Math.max(var1.width, var2.width), Math.max(var1.height, var2.height));
- }
-
- public Dimension minimumSize() {
- Dimension var1 = new Dimension(18, 10);
- Font var2 = ((Component)this).getFont();
- if (var2 == null) {
- if (this.bOsFlag) {
- var1.height = 29;
- }
- } else {
- var1.width = this.textWidth + 18;
- var1.height = this.textHeight + 10;
- if (this.bOsFlag && var1.height < 29) {
- var1.height = 29;
- }
- }
-
- return var1;
- }
-
- public synchronized void reshape(int var1, int var2, int var3, int var4) {
- super.reshape(var1, var2, var3, var4);
- if (!((Component)this).isValid()) {
- ((Component)this).repaint();
- }
-
- }
-
- public void update(Graphics var1) {
- this.paint(var1);
- }
- }
-